Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: sctp connection using usrsctp #11

Open
wants to merge 64 commits into
base: master
Choose a base branch
from
Open

feat: sctp connection using usrsctp #11

wants to merge 64 commits into from

Conversation

lchenut
Copy link
Collaborator

@lchenut lchenut commented Mar 8, 2024

Presentation

This PR is part of the stack to create the nim-libp2p webrtc-direct transport (defined here: https://github.com/libp2p/specs/blob/master/webrtc/webrtc-direct.md).
For this PR, we do not implement the full SCTP protocol, we are using the library usrsctp (nim wrapper: https://github.com/status-im/nim-usrsctp / C-library https://github.com/sctplab/usrsctp) to create and use SCTP channels.

SCTP

Stream Control Transmission Protocol (SCTP) is a transport-layer protocol used for transmitting multiple streams of data simultaneously between two endpoints, ensuring reliable, ordered delivery of messages. In the WebRTC stack, SCTP is employed to handle data channels, providing a reliable and unordered delivery of messages, which is critical for real-time communication applications. This allows WebRTC to efficiently transmit diverse types of data, such as text messages, file transfers, or application data, ensuring smooth and reliable communication between peers.

@lchenut lchenut self-assigned this Aug 19, 2024
@lchenut lchenut mentioned this pull request Aug 29, 2024
Comment on lines +9 to +12
let udp = UdpTransport.new(laddr)
let stun = Stun.new(udp)
let dtls = Dtls.new(stun)
let sctp = Sctp.new(dtls)
Copy link
Contributor

@diegomrsantos diegomrsantos Sep 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the final instance that matter is sctp, maybe we could just have something like Sctp.new(laddr)?

let sctp = Sctp.new(dtls)

let conn = await sctp.connect(initTAddress("127.0.0.1:4242"), sctpPort = 13)
while true:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could do this only a few times, maybe 10?

import ../webrtc/sctp/[sctp_transport, sctp_connection]

proc main() {.async.} =
let laddr = initTAddress("127.0.0.1:4244")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we fix a local address?


asyncTest "Two SCTP nodes connecting to each other, then sending/receiving data":
var
sctpServer = initSctpStack(initTAddress("127.0.0.1:4444"))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's better to use 0 port to avoid errors with port reuse.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: In Progress
Development

Successfully merging this pull request may close these issues.

2 participants